home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / SAT / Misc / FaceFromPICT.p < prev    next >
Encoding:
Text File  |  1994-07-26  |  1.4 KB  |  61 lines  |  [TEXT/PJMM]

  1. unit FaceFromPICT;
  2.  
  3. interface
  4.     uses
  5.         SAT; {SATGlobals, DisposeOffscreen, Offscreen;{SAT}
  6.  
  7.     function GetFaceFromPICT (colorPICTid, bwPICTid, maskPICTid: integer): FacePtr;
  8.  
  9. implementation
  10.  
  11. {No error checking yet!}
  12.  
  13.     function GetFaceFromPICT (colorPICTid, bwPICTid, maskPICTid: integer): FacePtr;
  14.         var
  15.             bounds: Rect;
  16.             thePICT, maskPICT: PicHandle;
  17.             theFace: FacePtr;
  18.             savePort: GrafPtr;
  19.             saveDev: GDhandle;
  20.     begin
  21.         SATGetPort(savePort, saveDev);
  22.  
  23. {Get PICTs}
  24. {IDEA: It should really check if the PICT it loads was loaded already, and if it was, don't dispose it.}
  25.         if gSAT.initDepth > 1 then
  26.             thePICT := GetPicture(colorPICTid)
  27.         else
  28.             thePICT := GetPicture(bwPICTid);
  29.         maskPICT := GetPicture(maskPICTid);
  30.         bounds := thePICT^^.picFrame;
  31.         OffsetRect(bounds, -bounds.left, -bounds.top); {onödigt för det gör NewFace åt oss.}
  32.  
  33.         if (thePICT = nil) or (maskPICT = nil) then
  34.             begin
  35.                 GetFaceFromPICT := nil;
  36.                 exit(GetFaceFromPICT);
  37.             end;
  38.  
  39. {Create face}
  40.         theFace := NewFace(bounds);
  41.  
  42. {Draw in the face}
  43.         SetPortFace(theFace);
  44.         DrawPicture(thePICT, bounds);
  45. {FrameRect(bounds); {DEBUG-rektangel}
  46.         SetPortMask(theFace);
  47.         DrawPicture(maskPICT, bounds);
  48. {FrameRect(bounds); {DEBUG-rektangel}
  49. {Tell SAT that we are done}
  50.         ChangedFace(theFace);
  51.  
  52. {Get rid of the PICTs}
  53.         ReleaseResource(Handle(thePICT));
  54.         ReleaseResource(Handle(maskPICT));
  55.  
  56. {Return the face.}
  57.         GetFaceFromPICT := theFace;
  58.  
  59.         SATSetPort(savePort, saveDev);
  60.     end;
  61. end.